﻿// =================================================================== 
// 业务逻辑层(GDIT.BLL)
//====================================================================
// 文件：BLinkInfo.cs
// 项目名称：学院网站
// 创建时间：2012-08-12
// 负责人：ChenZhiGang
//引用DevExpress.Data.Filtering，DevExpress.Xpo程序集
// 程序集介绍：链接信息操作逻辑
// ===================================================================
using DevExpress.Xpo;
using DevExpress.Data.Filtering;
using GDIT.Base.LogHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GDIT.Model;
using System.Data;

namespace GDIT.BLL
{
    public class BLinkInfo
    {
        private Pattern.DALAbstractFactory dataFactory = DataProvider.defaultProvider;

        /// <summary>
        /// 新增链接对象
        /// </summary>
        /// <param name="link">需要新增的链接对象</param>
        /// <returns>1：新增成功  0：新增失败</returns>
        public bool InsertLinkInfo(Mtb_LinkInfo link)
        {
            Logger.Info(String.Format("链接名字[{0}]", link.LinkName));
            int result = dataFactory.DALLinkInfoProvider.InsertLinkInfo(link);
            if (result == 1)
            {
                Logger.Info("Insert success");
                return true;
            }
            else
            {
                Logger.Info("Insert false");
                return false;
            }
        }

        /// <summary>
        /// 更新链接对象
        /// </summary>
        /// <param name="link">需要的链接对象</param>
        /// <returns>1：更新成功  0：更新失败</returns>
        public bool UpdateLinkInfo(Mtb_LinkInfo link)
        {
            Logger.Info(String.Format("链接名字[{0}]", link.LinkName));
            int result = dataFactory.DALLinkInfoProvider.UpdateLinkInfo(link);
            if (result == 1)
            {
                Logger.Info("Update success");
                return true;
            }
            else
            {
                Logger.Info("Update false");
                return false;
            }
        }

        /// <summary>
        /// 删除链接对象
        /// </summary>
        /// <param name="link">需要的链接对象</param>
        /// <returns>1：删除成功  0：删除失败</returns>
        public bool DeleteLinkInfo(Mtb_LinkInfo link)
        {
            Logger.Info(String.Format("链接名字[{0}]", link.LinkName));
            int result = dataFactory.DALLinkInfoProvider.DeleteLinkInfo(link);
            if (result == 1)
            {
                Logger.Info("Delete success");
                return true;
            }
            else
            {
                Logger.Info("Delete false");
                return false;
            }
        }

        /// <summary>
        /// 查询所有链接对象
        /// </summary>
        /// <returns>所有链接对象集合</returns>
        public IDataReader SelectAllLinkInfo()
        {
            return dataFactory.DALLinkInfoProvider.SelectAllLinkInfo();
        }

        /// <summary>
        /// 查询单一链接对象
        /// </summary>
        /// <param name="link">需要查询的链接对象条件</param>
        /// <returns>单一链接对象</returns>
        public Mtb_LinkInfo SelectLinkInfoByLink(Mtb_LinkInfo link)
        {
            return dataFactory.DALLinkInfoProvider.SelectLinkInfoByLink(link);
        }
    }
}
